<?php

namespace App\Http\Controllers\V1\User;

use App\Helpers\Resources;
use App\Http\Controllers\V1\BaseController;
use Dingo\Api\Http\Request;

class InfoController extends BaseController
{
    /**
     * Create a new controller instance.
     *
     * @return array
     */
    public function test(Request $request)
    {
        $appid = '2017072107832903';
        $encodeUrl = urldecode('http://test-love-api.bestpeng.com/api/test2');
//        $url = "https://openauth.alipaydev.com/oauth2/publicAppAuthorize.htm?app_id=$appid&scope=auth_user&redirect_uri=$encodeUrl";
        $url = "https://openauth.alipay.com/oauth2/publicAppAuthorize.htm?app_id=$appid&scope=auth_user&redirect_uri=$encodeUrl";
        $data = $request->all();

        if (count($data) > 1) {
            dd($data);
        } else {
            header("Location: $url");
        }

//        $accessToken = $request->input('auth');
//        $aop = new \AopClient ();
//        $aop->gatewayUrl = 'https://openapi.alipaydev.com/gateway.do';
//        $aop->appId = '2016080500175828';
//        $aop->rsaPrivateKey = 'MIIEpAIBAAKCAQEA4BLVnqCd/8+Fbkj31a1caRiJtEWL5KiDgLzqRx0WS7xcD/BzCAtyCyyvqHmyT7FgzYp38BXrHiRGiQ+RMRQeWxwSA0eDxDnescnIfh6U9W5dZ6dayQWZ+ixyav7HEHX3IeWdJr+woCvrpv444IkoiNJ315iYo4z5tt3YwUfoN73C/FP5LRC1Ow8Xp/C/AgyrGpggGUJkV9hSEoYMAH8bJXIH3KuvhxDG6tF+7IK78hEc4DiULjRyx6wfuRzCklROLesGZ2qsoI1nsKtsAgl0FcuNqS8QX1X2qkk8dEjUaV7ZLxPzZ2oh2tJeUCMxKcJergxxcUyDTampI9TBHpr+swIDAQABAoIBAAiTL/GeG+3KN0T9Ld7Tf5HWCo8Hik750+59TEnkZxIG508E2KIaLgcXcrFz1ssN8rJq9iQN8q14nepo2hmSt4atEFNnzTcZL9iF7FJHQVQTISfyU5sVx8q3ILnPfja3DPoTG2x8MXovtBjz6aFOHmr+AvAROuYnYvcIjl73LX/UhOigNKM6wdDuebHURwzI/iS6oQiJTBlGCtt9uagaS3CF2sm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nqCd/8+Fbkj31a1caRiJtEWL5KiDgLzqRx0WS7xcD/BzCAtyCyyvqHmyT7FgzYp38BXrHiRGiQ+RMRQeWxwSA0eDxDnescnIfh6U9W5dZ6dayQWZ+ixyav7HEHX3IeWdJr+woCvrpv444IkoiNJ315iYo4z5tt3YwUfoN73C/FP5LRC1Ow8Xp/C/AgyrGpggGUJkV9hSEoYMAH8bJXIH3KuvhxDG6tF+7IK78hEc4DiULjRyx6wfuRzCklROLesGZ2qsoI1nsKtsAgl0FcuNqS8QX1X2qkk8dEjUaV7ZLxPzZ2oh2tJeUCMxKcJergxxcUyDTampI9TBHpr+swIDAQAB';
//        $aop->apiVersion = '1.0';
//        $aop->signType = 'RSA2';
//        $aop->postCharset = 'GBK';
//        $aop->format = 'json';
//
//        $request = new \AlipayUserInfoShareRequest();
//        $result = $aop->execute($request, $accessToken);
//
//        $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
//        $resultCode = $result->$responseNode->code;
//
//        if (!empty($resultCode) && $resultCode == 10000) {
//            echo "成功";
//        }

//        return Resources::success($aopClient);
    }

    public function test2(Request $request)
    {
        $res = $request->all();
echo 1;exit;
        dd($res);
    }

}
